package com.xx.springboot.DataStructure.LeetCode.String;

/**
     编写一个函数，其作用是将输入的字符串反转过来。

     示例 1:

     输入: "hello"
     输出: "olleh"
     示例 2:

     输入: "A man, a plan, a canal: Panama"
     输出: "amanaP :lanac a ,nalp a ,nam A"
 */
public class reverseString {
    public String reverseString(String s) {
        char[] res = new char[s.length()];

        char[] str = s.toCharArray();
        for (int i = str.length - 1; i >= 0; i--)
            res[str.length - i - 1] = str[i];

        return new String(res);
    }

    public static void main(String[] args) {
        String str = ".,";
        reverseString reverseString = new reverseString();
        reverseString.reverseString(str);

        System.out.println(reverseString.reverseString(str));
    }
}
